package servise

import (
	"hxy/repo/database"
	errors "hxy/repo/error"
	"strconv"

	"github.com/emicklei/go-restful/v3"
)

func HandlerGetAllTask(request *restful.Request, response *restful.Response) {
	list := database.GetAllPipeline()
	response.WriteAsJson(list)
}
func HandleGetTaksbyGitid(request *restful.Request, response *restful.Response) {
	var id = request.PathParameter("gitid")
	aid, err := strconv.Atoi(id)
	if err != nil {
		errors.HandleInternalError(response, err)
		return
	}
	list := database.GetAllPipelinebyGitid(aid)
	response.WriteAsJson(list)
}
func HanderDockerTaskbyHash(request *restful.Request, response *restful.Response) {
	commit_hash := request.PathParameter("hash")
	list := database.DockerTaskByCommitHash(commit_hash)
	response.WriteAsJson(list)
}
